package main

import "fmt"

func main() {
	result := uniquePaths3D(3, 2, 1)
	fmt.Println(result)
}

func uniquePaths3D(l, m, n int) int {
	dp := make([][][]int, l)
	for i := range dp {
		dp[i] = make([][]int, m)
		for j := range dp[i] {
			dp[i][j] = make([]int, n)
		}
	}

	dp[0][0][0] = 1

	for i := 0; i < l; i++ {
		for j := 0; j < m; j++ {
			for k := 0; k < n; k++ {
				if i > 0 {
					dp[i][j][k] += dp[i-1][j][k]
				}
				if j > 0 {
					dp[i][j][k] += dp[i][j-1][k]
				}
				if k > 0 {
					dp[i][j][k] += dp[i][j][k-1]
				}
			}
		}
	}

	return dp[l-1][m-1][n-1]
}
